import request from '@/utils/request'
import {praseStrEmpty} from "@/utils/lfs";

// 查询通道组列表
export function channelGroupList(query) {
  return request({
    url: '/lfs-admin/channelGroup/queryChannelGroupList',
    method: 'post',
    params: query
  })
}

// 查询通道下拉列表
export function getChannelList() {
  return request({
    url: '/lfs-admin/channel/getChannelList',
    method: 'post'
  })
}

// 查询通道下拉列表
export function getSelectChannel(groupNum) {
  const data = {
    groupNum
  }
  return request({
    url: '/lfs-admin/channel/getSelectChannel',
    method: 'post',
    params: data
  })
}

// 查询通道组详细
export function getChannelGroup(id) {
  return request({
    url: '/lfs-admin/channelGroup/getChannelGroup/' + praseStrEmpty(id),
    method: 'get'
  })
}

// 新增通道组
export function addChannelGroup(data) {
  return request({
    url: '/lfs-admin/channelGroup/addChannelGroup',
    method: 'post',
    data: data
  })
}

// 新增通道到通道组
export function addChannelToGroup(channelNums,id) {
  const data = {
    channelNums,
    id
  }
  return request({
    url: '/lfs-admin/channelGroup/addChannelToGroup',
    method: 'post',
    data: data
  })
}

// 修改通道组
export function updateChannelGroup(data) {
  return request({
    url: '/lfs-admin/channelGroup/updateChannelGroup',
    method: 'put',
    data: data
  })
}

// 删除通道组
export function delChannelGroup(ids) {
  return request({
    url: '/lfs-admin/channelGroup/delChannelGroup/' + ids,
    method: 'delete'
  })
}

// 查询通道组下通道列表
export function getChannelToGroup(query) {
  return request({
    url: '/lfs-admin/channelGroup/getChannelToGroup',
    method: 'post',
    params: query
  })
}

// 修改通道组下通道
export function updateWeight(channelGroupId,channelNum,weight) {
  const data = {
    channelGroupId,
    channelNum,
    weight
  }
  return request({
    url: '/lfs-admin/channelGroup/updateWeight',
    method: 'put',
    data: data
  })
}

// 修改通道组下通道是否默认
export function updateIsDefault(id,isDefault) {
  const data = {
    id,
    isDefault
  }
  return request({
    url: '/lfs-admin/channelGroup/updateChannelGroup',
    method: 'put',
    data: data
  })
}


// 删除通道组下通道
export function delChannelToGroup(ids) {
  return request({
    url: '/lfs-admin/channelGroup/delChannelToGroup/' + ids,
    method: 'delete'
  })
}


